//
//  CreatModel.m
//  快速创建model
//
//  Created by pFlower on 15-10-8.
//  Copyright (c) 2015年 LYHeng. All rights reserved.
//

#import "CreatModel.h"

@implementation CreatModel
+(void)createJsonModelWithDictionary:(NSDictionary *)dic
{
    for (NSString *key in dic) {
        //        NSString *type = ([dict[key] isKindOfClass:[NSNumber class]])?@"NSNumber":@"NSString";
        if ([dic[key] isKindOfClass:[NSString class]]) {
            printf("@property (nonatomic,retain) NSString *%s;\n",key.UTF8String);
        }
        if ([dic[key] isKindOfClass:[NSNumber class]]) {
            printf("@property (nonatomic,retain) NSNumber *%s;\n",key.UTF8String);
        }
        if ([dic[key] isKindOfClass:[NSArray class]]) {
            printf("@property (nonatomic,retain) NSArray *%s;\n",key.UTF8String);
        }
        if ([dic[key] isKindOfClass:[NSDictionary class]]) {
            printf("@property (nonatomic,retain) NSDictionary *%s;\n",key.UTF8String);
        }
    }
}


+(void)creatModelAcoder:(NSDictionary *)dic
{
    for (NSString *key in dic) {
        printf("[aCoder encodeObject:self.%s forKey:@\"%s\"];\n",key.UTF8String,key.UTF8String);
    }
}
+(void)creatModelADecoder:(NSDictionary *)dic
{
    for (NSString *key in dic) {
        printf("self.%s = [aDecoder decodeObjectForKey:@\"%s\"];\n",key.UTF8String,key.UTF8String);
    }
}
@end
